{% extends "base_fullpage.html" %}

{% set is_new = container is none %}

{% block subtitle %}{% if is_new %}New container{% else %}Update container {{ container.name }} {% endif %}{% endblock %}

{% block content %}

<h2>{% if is_new %}New container{% else %}Update container {{ container.name }} {% endif %}</h2>

<form action="/container/update" method="POST">
  <label for="name">Name</label>
  <input id="name" type="text" name="name" value="{{ container.name }}" maxlength="100"/>
  <br/>

  <label for="description">Description</label>
  <textarea id="description" name="description">{{ container.description }}</textarea>
  <br/>

  <label for="location">Location</label>
  <select name="location" id="location">
  {% for su in storage_units %}
    <optgroup label="{{ su.name }}">
    {% for slot in su.slots %}
      <option value="{{ su.key.urlsafe() }} {{ loop.index0 }}" {% if su.key == container.storage_unit and slot == container.slot %}selected="selected"{% endif %}>{{ su.name}}: {{ slot }}</option>
    {% endfor %}
    </optgroup>
  {% endfor %}
  </select>
  <br/>


  {% if is_new %}
  <input type="submit" name="action" value="Create" />
  <input type="submit" name="action" value="Cancel" />
  {% else %}
  <input type="hidden" name="key" value="{{ container.key.urlsafe() }}" />
  <input type="submit" name="action" value="Update" />
  <input type="submit" name="action" value="Cancel" />
  <input type="submit" name="action" value="Delete" />
  {% endif %}
</form>

{% endblock %}
